using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using Newtonsoft.Json;
using Triton.Common;
using Triton.Game;

namespace Triton.Bot.Settings
{
	public class MainSettings : JsonSettings
	{
		private static MainSettings mainSettings_0;

		private string string_1;

		private string string_2;

		private List<string> list_0;

		private bool bool_0;

		private int int_0;

		private int int_1;

		private int int_2;

		private int int_3;

		private int int_4;

		private int int_5;

		private string string_3;

		private string string_4;

		private string string_5;

		private bool bool_1;

		private bool bool_2;

		private bool bool_3;

		private bool bool_4;

		private int int_6;

		private ObservableCollection<CustomDeckCache> observableCollection_0;

		public static MainSettings Instance => mainSettings_0 ?? (mainSettings_0 = new MainSettings());

		[DefaultValue(0)]
		public int LastDeckCachePid
		{
			get
			{
				return int_6;
			}
			set
			{
				if (!value.Equals(int_6))
				{
					int_6 = value;
					NotifyPropertyChanged(() => LastDeckCachePid);
				}
			}
		}

		[DefaultValue(false)]
		public bool AllowExternalAccess
		{
			get
			{
				return bool_0;
			}
			set
			{
				if (!value.Equals(bool_0))
				{
					bool_0 = value;
					NotifyPropertyChanged(() => AllowExternalAccess);
				}
			}
		}

		[JsonIgnore]
		[DefaultValue(0)]
		public int AccessToken
		{
			get
			{
				return int_0;
			}
			set
			{
				if (!value.Equals(int_0))
				{
					int_0 = value;
					NotifyPropertyChanged(() => AccessToken);
				}
			}
		}

		[JsonIgnore]
		public ObservableCollection<CustomDeckCache> CustomDecks
		{
			get
			{
				return observableCollection_0;
			}
			set
			{
				if (!value.Equals(observableCollection_0))
				{
					observableCollection_0 = value;
					NotifyPropertyChanged(() => CustomDecks);
				}
			}
		}

		[DefaultValue(false)]
		public bool ShowGlobalTab
		{
			get
			{
				return bool_4;
			}
			set
			{
				if (!value.Equals(bool_4))
				{
					bool_4 = value;
					NotifyPropertyChanged(() => ShowGlobalTab);
				}
			}
		}

		[DefaultValue(false)]
		public bool ShowConfigurationTab
		{
			get
			{
				return bool_3;
			}
			set
			{
				if (!value.Equals(bool_3))
				{
					bool_3 = value;
					NotifyPropertyChanged(() => ShowConfigurationTab);
				}
			}
		}

		[DefaultValue(false)]
		public bool ShowDevTab
		{
			get
			{
				return bool_1;
			}
			set
			{
				if (!value.Equals(bool_1))
				{
					bool_1 = value;
					NotifyPropertyChanged(() => ShowDevTab);
				}
			}
		}

		[DefaultValue(false)]
		public bool ShowToolsTab
		{
			get
			{
				return bool_2;
			}
			set
			{
				if (!value.Equals(bool_2))
				{
					bool_2 = value;
					NotifyPropertyChanged(() => ShowToolsTab);
				}
			}
		}

		[DefaultValue("295*")]
		public string TopRowDefinitionHeight
		{
			get
			{
				return string_3;
			}
			set
			{
				if (!value.Equals(string_3))
				{
					string_3 = value;
					NotifyPropertyChanged(() => TopRowDefinitionHeight);
				}
			}
		}

		[DefaultValue("175*")]
		public string BottomRowDefinitionHeight
		{
			get
			{
				return string_4;
			}
			set
			{
				if (!value.Equals(string_4))
				{
					string_4 = value;
					NotifyPropertyChanged(() => BottomRowDefinitionHeight);
				}
			}
		}

		[DefaultValue("Auto")]
		public string SplitterRowDefinitionHeight
		{
			get
			{
				return string_5;
			}
			set
			{
				if (!value.Equals(string_5))
				{
					string_5 = value;
					NotifyPropertyChanged(() => SplitterRowDefinitionHeight);
				}
			}
		}

		[DefaultValue(5)]
		public int MsBetweenTicks
		{
			get
			{
				return BotManager.MsBetweenTicks;
			}
			set
			{
				if (value > 5) BotManager.MsBetweenTicks = 5;
				else BotManager.MsBetweenTicks = value;
				NotifyPropertyChanged(() => MsBetweenTicks);
			}
		}

		public int InputEventMsDelay
		{
			get
			{
				return Input.InputEventMsDelay;
			}
			set
			{
				if (value > 5) Input.InputEventMsDelay = 5;
				else Input.InputEventMsDelay = value;
				NotifyPropertyChanged(() => InputEventMsDelay);
			}
		}

		[DefaultValue(1000)]
		public int MsBetweenGuiTicks
		{
			get
			{
				return int_5;
			}
			set
			{
				if (!value.Equals(int_5))
				{
					int_5 = value;
					NotifyPropertyChanged(() => MsBetweenGuiTicks);
				}
			}
		}

		[DefaultValue(0)]
		public int WindowX
		{
			get
			{
				return int_3;
			}
			set
			{
				if (!value.Equals(int_3))
				{
					int_3 = value;
					NotifyPropertyChanged(() => WindowX);
				}
			}
		}

		[DefaultValue(0)]
		public int WindowY
		{
			get
			{
				return int_4;
			}
			set
			{
				if (!value.Equals(int_4))
				{
					int_4 = value;
					NotifyPropertyChanged(() => WindowY);
				}
			}
		}

		[DefaultValue(627)]
		public int WindowWidth
		{
			get
			{
				return int_1;
			}
			set
			{
				if (!value.Equals(int_1))
				{
					int_1 = value;
					NotifyPropertyChanged(() => WindowWidth);
				}
			}
		}

		[DefaultValue(600)]
		public int WindowHeight
		{
			get
			{
				return int_2;
			}
			set
			{
				if (!value.Equals(int_2))
				{
					int_2 = value;
					NotifyPropertyChanged(() => WindowHeight);
				}
			}
		}

		[DefaultValue("DefaultBot")]
		public string LastBot
		{
			get
			{
				return string_1;
			}
			set
			{
				if (!value.Equals(string_1))
				{
					string_1 = value;
					NotifyPropertyChanged(() => LastBot);
				}
			}
		}

		[DefaultValue("DefaultRoutine")]
		public string LastRoutine
		{
			get
			{
				return string_2;
			}
			set
			{
				if (!value.Equals(string_2))
				{
					string_2 = value;
					NotifyPropertyChanged(() => LastRoutine);
				}
			}
		}

		public List<string> EnabledPlugins
		{
			get
			{
				return list_0;
			}
			set
			{
				if (!value.Equals(list_0))
				{
					list_0 = value;
					NotifyPropertyChanged(() => EnabledPlugins);
				}
			}
		}

		public MainSettings()
			: base(JsonSettings.GetSettingsFilePath(Configuration.Instance.Name, string.Format("{0}.json", "Main")))
		{
			if (list_0 == null)
			{
				list_0 = new List<string> {};
			}
			if (observableCollection_0 == null)
			{
				observableCollection_0 = new ObservableCollection<CustomDeckCache>();
			}
		}

		public void LoadRowDefinitions(RowDefinition topRowDefinition, RowDefinition splitterRowDefinition, RowDefinition bottomRowDefinition)
		{
			GridLengthConverter gridLengthConverter = new GridLengthConverter();
			topRowDefinition.Height = (GridLength)gridLengthConverter.ConvertFromString(TopRowDefinitionHeight);
			splitterRowDefinition.Height = (GridLength)gridLengthConverter.ConvertFromString(SplitterRowDefinitionHeight);
			bottomRowDefinition.Height = (GridLength)gridLengthConverter.ConvertFromString(BottomRowDefinitionHeight);
		}

		public void SaveRowDefinitions(RowDefinition topRowDefinition, RowDefinition splitterRowDefinition, RowDefinition bottomRowDefinition)
		{
			GridLengthConverter gridLengthConverter = new GridLengthConverter();
			TopRowDefinitionHeight = gridLengthConverter.ConvertToString(topRowDefinition.Height);
			SplitterRowDefinitionHeight = gridLengthConverter.ConvertToString(splitterRowDefinition.Height);
			BottomRowDefinitionHeight = gridLengthConverter.ConvertToString(bottomRowDefinition.Height);
		}
	}
}
